<?php
/**
 * Created by PhpStorm.
 * User: ship
 * Date: 2024/12/30
 * Time: 14:00
 */

namespace ShipSun\LaravelRequestResponseJm;

use Illuminate\Http\Request;

/**
 * Class RequestDecryptMiddleware
 * @package ShipSun\LaravelRequestResponseJm
 */
class RequestDecryptMiddleware extends BaseMiddleware
{
    public static $request_method = [];

    public function handle(Request $request, \Closure $next)
    {
        if ($this->isJm($request)) {
            $request = $this->encrypter->decrypt($request);
        }
        return $next($request);
    }
    /**
     * @param Request $request
     * @return bool
     */
    protected function allowMethod(Request $request)
    {
        if (in_array(strtolower($request->getMethod()), static::$request_method)) {
            return true;
        }
        return false;
    }
}